package cn.weekimwee.firstlineofcodeforkotlin.unit12

import android.os.Bundle
import android.view.MenuItem
import cn.weekimwee.firstlineofcodeforkotlin.BaseActivity
import cn.weekimwee.firstlineofcodeforkotlin.GlideApp
import cn.weekimwee.firstlineofcodeforkotlin.R
import kotlinx.android.synthetic.main.activity_floating_action_button.*

class FruitDetailActivity : BaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_floating_action_button)
        setSupportActionBar(toolbar)
        supportActionBar?.setDisplayHomeAsUpEnabled(true)
        collapsing_toolbar.title = "西瓜"
        GlideApp.with(this).load("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1523458728133&di=fc2a4f6a288d79050b75537229130350&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2Fc83d70cf3bc79f3db0debe22b0a1cd11728b29e0.jpg").into(fruit_image)
        fruitContent.text = getContent()
    }

    private fun getContent(): String {
        val stringBuilder = StringBuilder()
        for(i in  0..500){
            stringBuilder.append("西瓜")
        }
        return stringBuilder.toString()
    }

    override fun onOptionsItemSelected(item: MenuItem?): Boolean {
        when(item?.itemId){
            android.R.id.home->{
                finish()
                return true
            }
        }
        return super.onOptionsItemSelected(item)
    }
}
